# 拆分、排序、求和

class Solution(object):
    def minimumSum(self, num):
        """
        :type num: int
        :rtype: int
        """
        num = str(num)
        num = [int(i) for i in num]
        num.sort() # 默认是升序; 降序：num.sort(reverse=True)
        return num[0]*10 + num[2] + num[1] * 10 + num[3]
if __name__ == '__main__':
    num = 4009
    result = Solution().minimumSum(num)
    print(result)